//
//  ShaDetailSizeModel.m
//  YiXiu
//
//  Created by yixiu on 16/8/2.
//  Copyright © 2016年 zzz. All rights reserved.
//

#import "ShaDetailSizeModel.h"

#define OriginOfView(view) (view).bounds.origin
#define SizeOfView(view) (view).bounds.size
#define WidthOfView(view) (view).bounds.size.width
#define HeightOfView(view) (view).bounds.size.height

#define HeightOfRect(view) (view).size.height

@implementation ShaDetailSizeModel


//根据传入text的字体和数量计算其高
- (CGSize)sizeOfString:(NSString *)str font:(UIFont *)font{
    
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    dic[NSFontAttributeName] = font;
    CGRect rect = [str boundingRectWithSize:CGSizeMake(WidthOfView([UIScreen mainScreen]) - 20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    return rect.size;
}



- (void)setModel:(ShaDetalModel *)model{
    
    _model = model;
    
    CGSize pt_fragment_size = [self sizeOfString:model.pt_fragment font:[UIFont systemFontOfSize:14]];
    
    
    self.p_headline = CGRectMake(10, 0, KScreenWidth - 20, 40);
    
    self.p_date = CGRectMake(10, CGRectGetMaxY(self.p_headline) + 10, KScreenWidth - 20, 30);
    
    if (model.pt_url && model.pt_url.length > 0) {
        self.imageS = [model.pt_url componentsSeparatedByString:@","];
        
        self.pt_url = CGRectMake(10, CGRectGetMaxY(self.p_date) + 10, KScreenWidth - 20, 200 * self.imageS.count);
        
    }else{
        self.pt_url = CGRectMake(10, CGRectGetMaxY(self.p_date) + 10, KScreenWidth - 20, 0.001);
    }
    
    self.pt_fragment = CGRectMake(10, CGRectGetMaxY(self.pt_url) + 10, pt_fragment_size.width, pt_fragment_size.height);
    
    self.totalHeight = CGRectGetMaxY(self.pt_fragment) + 10;
    
}





@end
